package com.stylefeng.guns.biz.api.controller;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.result.BaseResultVo;
import com.stylefeng.guns.modular.platform.model.SellerDemand;
import com.stylefeng.guns.modular.platform.service.ISellerDemandService;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2018-07-13 19:10:46
 */
@Controller
@RequestMapping("/api/pc/sellerDemand")
public class ApiSellerDemandController extends BaseController {

	@Autowired
	private ISellerDemandService sellerDemandService;
	
	/**
	 * 获取列表
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public BaseResultVo list(Page<SellerDemand> page,String userId) {
		EntityWrapper<SellerDemand> wp = new EntityWrapper<SellerDemand>();
		wp.eq("user_id", userId);
		return sellerDemandService.selectSellerDemandPage(page,wp);
	}
	
	/**
	 * 新增
	 */
	@RequestMapping(value = "/add")
	@ResponseBody
	public BaseResultVo add(@RequestBody  SellerDemand sellerDemand) {
		return sellerDemandService.addSellerDemand(sellerDemand);
	}
	
	/**
	 * 删除
	 */
	@RequestMapping(value = "/delete")
	@ResponseBody
	public BaseResultVo delete(@RequestParam Integer sellerDemandId) {
		return sellerDemandService.deleteSellerDemandById(sellerDemandId);
	}
	
	/**
	 * 修改
	 */
	@RequestMapping(value = "/update")
	@ResponseBody
	public BaseResultVo update(SellerDemand sellerDemand) {
		return sellerDemandService.updateSellerDemandById(sellerDemand);
	}
	
	/**
	 * 详情
	 */
	@RequestMapping(value = "/detail/{sellerDemandId}")
	@ResponseBody
	public BaseResultVo detail(@PathVariable("sellerDemandId") Integer sellerDemandId) {
		return sellerDemandService.selectSellerDemandById(sellerDemandId);
	}
}
